<template>
  <div>
    <router-view/>
    <NotifyDialog ref="notifyDialog" @read="handleRead"/>
    <ChatPanel v-if="chatPanelVisible" @close="handleClose"/>
  </div>
</template>
<script>
import NotifyDialog from "@/components/NotifyDialog";
import ChatPanel from "@/components/ChatPanel";
export default {
  components: {ChatPanel, NotifyDialog},
  data(){
    return{
      chatPanelVisible: false
    }
  },
  methods:{
    handleRead(reminderId){
      this.$http.post(`reminder/seen/${reminderId}`).then((response)=>{
        if (response.data.code == 1){
          console.log("已更新为已读")
        }else {
          console.log("更新失败")
        }
      })
    },
    handleClose(){
      this.chatPanelVisible = false
    }
  },
  mounted() {
    this.$bus.$on('showNotifyDialog', (msgObj) => {
      this.$refs.notifyDialog.showDialog(msgObj)
    })
    this.$bus.$on('showChatPanel', () => {
      this.chatPanelVisible = true
    })
  }
}
</script>
